<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
</head>
<body>
    <div id="app">
        qq:<input type="text" v-model="qq">
        qq邮箱:<input type="text" :value="qqemail">
        <h1>{{newVal}}</h1>
        <h1>{{oldVal}}</h1>
    </div>
    <script>
        var vm = new Vue({
            el:"#app",
            data:{
                qq:"",
                qqemail:"222",
                newVal:"",
                oldVal:"",
            },
            watch:{
                // 方法有两个参数，一个是新的值，一个是老的值
                qq:function(newVal,oldVal){
                    this.qqemail=this.qq+"@qq.coom"
                    this.newVal = newVal
                    this.oldVal = oldVal
                }
            }
        })
    </script>
</body>
</html>